<template>
	<view>
		<div class='odiv'>
			<web-view :webview-styles="{width: '100%',height: '200px'}" :src="url"></web-view>
		</div>
	</view>
</template>

<script>
	import {
		getShareTitle
	} from '@/api/public.js'
	import {
		siteConfig
	} from '@/api/api.js'
	export default {
		components: {},

		data() {
			return {
				is_diy: uni.getStorageSync('is_diy'),
				url: '',
				share_title: "智能名片"
			};
		},
		onLoad(options) {
			console.log(options);
			if (options.url) {
				this.url = decodeURIComponent(options.url)
				this.share_title = '私人助理'
				if(options.title){
					this.share_title = options.title
				}
			} else {
				this.getURL()
			}
		},
		onShow() {
			
		},
		onShareAppMessage(e) {
			
			return { // 自定义分享内容
				title: this.share_title,
				path: `/pages/webview/webview?url=`+encodeURIComponent(this.url)
			}
		},
		// onShareTimeline() {
		// 	return {
		// 		title: this.share_title,
		// 		path: `/pages/webview/webview?url=`+encodeURIComponent(this.url)
		// 	};
		// },
		onShareTimeline(e){
			return {
				title: "私人助理",
				path: "/pages/index/minp?share_uid=1",
			}
		},
		methods: {
			getURL() {
				siteConfig().then(res => {
					console.log(res.data.mini_site_url, "res")
					if (res.data.mini_site_url.indexOf('https') != -1) {
						this.url = res.data.mini_site_url
						this.share_title = res.data.websiteShareTitle
					} else {
						uni.navigateTo({
							url: res.data.mini_site_url
						})
					}
				}).catch(err => {
					console.error(err.msg);
				});
			}
		}
	}
</script>

<style lang="scss">
	.odiv {
		width: 100%;
		height: 95vh;
	}
</style>